import React, { Component } from "react";
import "./getNew.less";
import { reqgetnew } from "../../../../http/api";
import { $pre } from "../../../../http/http";
import { Link } from "react-router-dom";
export default class getNew extends Component {
  constructor() {
    super();
    this.state = {
      newlist: [],
    };
  }
  componentDidMount() {
    reqgetnew().then((res) => {
      this.setState({
        newlist: res.data.list,
      });
    });
  }
  render() {
    let { newlist } = this.state;
    return (
      <div>
        <div className="box">
          <span className="h3">新人专享</span>
          <span>2022-2-20</span>
          <span>查看全部</span>
        </div>

        <div className="new">
          {newlist.map((item) => {
            return (
              <div className="newclass" key={item.id}>
                <Link to={"/detail/" + item.id}>
                  <img src={$pre + item.img} alt="" />
                  <span>{item.goodsname}</span>
                </Link>
              </div>
            );
          })}
        </div>
      </div>
    );
  }
}
